﻿using System.Net;
using System.Net.Http;
using Volo.Abp;

namespace Joy.Erp.Ufida.Core
{
    public static class HttpExtensions
    {
        public static void HandStatusCode(this HttpResponseMessage response, string url)
        {
            if (response.StatusCode == HttpStatusCode.NotFound)
                throw new BusinessException("BasicArchives:101").WithData("Url", url);
            if (response.StatusCode != HttpStatusCode.OK)
                throw new BusinessException("BasicArchives:102")
                    .WithData("Url", url)
                    .WithData("StatusCode", response.StatusCode);
        }
    }
}
